<template>
	<view class="app">
		<text class="address_item_title">地址别名</text>
		<view class="address_item_tab">
			<input class="address_input" type="text" v-model="data.name" placeholder="地址别名" placeholder-class="address_placeholder" />
		</view>
		<text class="address_item_title">LHT地址</text>
		<view class="address_item_tab">
			<input class="address_input" type="text" v-model="data.address" placeholder="输入或粘入地址" placeholder-class="address_placeholder" />
		</view>
		
		<view class="add_btn" @click="submit">确定</view>
	</view>
</template>

<style>
	/* 相对路径 */
	@import url('./addAddress.css');
</style>


<script>
	export default {
		data() {
			return {
				data: {}
			}
		},
		onLoad(options) {
			
		},
		methods: {
			async submit(){
				const data = this.data;
				if(!data.name){
					this.$util.msg('请输地址别名');
					this.$refs.confirmBtn.stop();
					return;
				}
				if(!data.address){
					this.$util.msg('请输入LHT地址');
					this.$refs.confirmBtn.stop();
					return;
				}
				const res = await this.$request('lhtAddress', 'add', data);
				this.$util.msg(res.msg);
				if(res.status === 1){
					this.$util.prePage().loadData();
					setTimeout(()=>{
						uni.navigateBack();
					}, 1000)
				}
			}
		}
	}
</script>
